package cn.dd.crmweb.modules.audio.controller;


import cn.dd.crmweb.common.Result;
import cn.dd.crmweb.modules.audio.entity.Audio;
import cn.dd.crmweb.modules.audio.mapper.AudioMapper;
import cn.dd.crmweb.modules.audio.service.IAudioService;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("audio")
public class AudioController {

    @Autowired
    private IAudioService audioService;
    @Autowired
    private AudioMapper audioMapper;

    @GetMapping("list")
    public Result findAll(){
        return Result.success(audioService.list());
    }

    @PostMapping("/update/emotion")
    public Result updateEmotion(@RequestBody Map<String,Object> map){
        UpdateWrapper<Audio> updateWrapper = new UpdateWrapper<>();
        updateWrapper.eq("name",map.get("name")).set("label_type", map.get("labelType"));
        boolean bo = audioService.update(null, updateWrapper);
        if (bo){
            return Result.success("updated");
        }
        return Result.error();
    }
}
